1. Field of the Invention
This invention relates generally to computer software. More particularly, the invention relates to a system and method for intercepting programmatic access of a native code module performed during execution of virtual machine bytecode and modifying the native code module by adding additional code operable to determine information regarding execution of the native code module.
2. Description of the Related Art
Software developers typically create the source code for software applications in a high-level programming language by writing textual program statements that specify the application's functionality. The source code may then be compiled into executable machine code that can be executed by a physical processor. This executable machine code is also referred to as native code because it is formatted so that it executes on a specific type of processor using that processor's instruction set. Thus, native code is typically not portable across different types of computing devices, e.g., devices that use different types of processors.
An alternative method of program execution is to compile the source code into an intermediate form of code called bytecode, which is a binary representation of program instructions suitable for execution on a specific type of virtual machine. The virtual machine itself is implemented in software and is executed by the processor of the physical computing device. A software application that has been compiled into bytecode instructions may be executed on the virtual machine, e.g., by the virtual machine dynamically interpreting the bytecode instructions. Alternatively, another level of compilation may be performed. For example, some virtual machine runtime environments perform just-in-time compilation to compile bytecode into native code during execution of the software application.
The virtual machine provides a layer of abstraction between the compiled bytecode and the underlying hardware platform and operating system. Thus, compiling a software application into bytecode rather than native code may reduce the software application's dependence on specific hardware. For example, the same bytecode may be executed on several different types of computing platforms as long as a virtual machine to execute the bytecode is available on all the respective computing platforms.
While implementing a software application as virtual machine bytecode may have advantages in terms of portability, some tasks are impossible or inefficient to do in bytecode and can be done better using native code. Thus, some software applications use both hardware-independent virtual machine bytecode and native code compiled for a specific type of computing hardware or platform. For example, the software application may be implemented with bytecode where possible, and the bytecode may invoke native code routines when it is necessary to use features dependent on the host environment.